#coding=utf-8
import sys
sys.path.append("..")
from config.config import * #导入config包里的config模块里所有的内容
import time
import unittest
from public.utiles.HTMLTestRunnerNew import HTMLTestRunner
#定义生成测试报告的路径及文件名称
now = time.strftime('%Y-%m-%d-%H-%M-%S')   #定义时间戳
# print(now)
filename = report_path + '\\' + str(now) + "_ui_report.html"
# print(filename)

def auto_run():
    discover = unittest.defaultTestLoader.discover(start_dir=testcase_path,
                                                   pattern='test*.py')
    f = open(filename,'wb')
    runner = HTMLTestRunner(stream=f,
                            title='cms后台系统ui自动化测试报告',
                            description='测试用例执行如下',
                            tester='小周')
    runner.run(discover)
    f.close() #关闭文件

if __name__ == '__main__':
    auto_run()
